package com.woniu.controller;


import org.springframework.ai.chat.model.ChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/ai")
@CrossOrigin
public class BailianAgentStreamController {
    @Autowired
    ChatModel chatModel;
    //text/event-stream 就是SSE模式，单向推送 长数据拆分成短数据响应
    @GetMapping(value="/stream", produces="text/event-stream")
    public Flux<String> stream(@RequestParam(value = "message") String message) {
        return chatModel.stream(message);
    }
}
